<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>日记详情</title>
    <link rel="stylesheet" type="text/css" href="/bootstrap-3.4.1-dist/css/bootstrap.css">
    <style>
        .right {
            padding: 40px;
        }

        a {
            color: white;
            text-decoration: none;
        }

        a:hover {
            color: white;
            text-decoration: none;
        }
    </style>
    <script type="text/javascript" src="/script/jquery.min.1.10.2.js"></script>
    <script type="text/javascript">
        $(function () {
        })
    </script>
</head>
<body>
<div class="right">
    <a href="/diary/insertPage">
        <button class="btn btn-success" style="margin-bottom: 40px" id="z_xy">
            新增日记
        </button>
    </a>
    <table class="table table-hover">
        <thead>
        <tr class="info">
            <th>日记id</th>
            <th>时间</th>
            <th>日记分组</th>
            <th>日记内容</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="d:${diaries}">
            <td th:text="${d.id}"></td>
            <td th:text="${#dates.format(d.time,'yyyy-MM-dd')}"></td>
            <td th:text="${d.gName}"></td>
            <td th:text="${d.context}"></td>
            <td>
                <script type="text/javascript" th:inline="javascript">
                    var deleteDiary = function (id, gId) {
                        $.ajax({
                            type: 'GET',
                            url: "/diary/delete",
                            data: {
                                "id": id,
                                "gId": gId
                            },
                            success: function (data) {
                                alert("删除成功！");
                                location.href = "http://localhost:8080/diary/diaryDetail"
                            }
                        })
                    }
                </script>
                <button class="btn btn-danger" id="delete" th:onclick="deleteDiary([[${d.id}]],[[${d.gId}]])">删除
                </button>
                <a th:href="@{/diary/updatePage(id=${d.id},gId=${d.getGId()})}">
                    <button class="btn btn-warning" id="update">
                        修改
                    </button>
                </a>
            </td>
        </tr>
        </tbody>
    </table>
    <!--分页栏-->
    <!--<div class="pages">
        <button class="btn btn-link">上一页</button>
        <input  type="number" value="1" class="form-control" style="display: inline-block;width: 60px;">
        <button class="btn btn-link">下一页</button>
    </div>-->
</div>
</body>
</html>
